package com.kuang.conroller;

import com.kuang.pojo.Exam;
import com.kuang.pojo.Logs;
import com.kuang.pojo.Qquestion;
import com.kuang.pojo.Rank;
import com.kuang.service.CandidateService;
import com.kuang.service.CodeService;
import com.kuang.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class JspController {
    //验证用户是否可以登录

    @Autowired
    @Qualifier("ExamServiceImpl")
    private com.kuang.service.ExamService ExamService;

    @Autowired
    @Qualifier("CandidateServiceImpl")
    private com.kuang.service.CandidateService CandidateService;

    @Autowired
    @Qualifier("PaperServiceImpl")
    private com.kuang.service.PaperService PaperService;

    @Autowired
    @Qualifier("LogsServiceImpl")
    private com.kuang.service.LogsService LogsService;

    @RequestMapping("/bm")
    public String goBaoming(){

        return "dating";
    }
    @RequestMapping("/wd")
    public String goWode(HttpSession session,Model model){
        Object o=session.getAttribute("USERID");
        int useriid=Integer.parseInt(o==null?"":o.toString());
        int cid=CandidateService.getCByUid(useriid).getCID();
        session.setAttribute("CID",cid);
        List<Exam> allexams=ExamService.allExam(cid);
        model.addAttribute("allexams",allexams);
        return "baoming1";
    }
    @RequestMapping("/phb")
    public String goPhb(Model model){
        List<Rank> rankList=ExamService.getRank();
        System.out.println(rankList);
        model.addAttribute("rankList",rankList);
        return "paihangbang";
    }

    @RequestMapping("/loginout")
    public String goOut(HttpSession session){
        session.removeAttribute("USERID");
        session.removeAttribute("RNAME");
        session.removeAttribute("CID");
        session.removeAttribute("EID");
        return "shouye";
    }

    @RequestMapping("/shouye")
    public String goIn(){
        return "shouye";
    }

    @RequestMapping("/cs")
    public String addTest( Model model){
        List<Qquestion> qlist=PaperService.addTest();
        model.addAttribute("qlist",qlist);
        return "ceshi";
    }

    @RequestMapping("/ct")
    public String allCuoti( Model model){
        List<Qquestion> wlist=PaperService.getWrong();
        model.addAttribute("wlist",wlist);
        return "cuoti";
    }

    @RequestMapping("/zhuce")
    public String register( ){
        return "zhuce";
    }

    @RequestMapping("/logs")
    public String allLogs( Model Model){
        List<Logs> llist=LogsService.allLogs();
        Model.addAttribute("llist",llist);
        return "logs";
    }
}
